package com.garlicts.framework.crawler;

import java.util.Objects;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;

import com.gargoylesoftware.htmlunit.WebClient;

public class WebClientPoolConfig extends GenericObjectPoolConfig<WebClient> {

	public WebClientPoolConfig(Integer crawlerNumber){
		
		final Integer availableProcessors;
		
		if(Objects.equals(crawlerNumber, null)) {
			availableProcessors = Runtime.getRuntime().availableProcessors() * 2;	
		}else {
			availableProcessors = crawlerNumber;
		}
		
		setMaxTotal(availableProcessors);
		setTestOnBorrow(true);
		
	}
	
}
